class Solution(object):
    def checkPossibility(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        count = 0
        index = 0
        n = len(nums)

        def search(index, n):
            while index < n - 1:
                if nums[index] > nums[index + 1]:
                    return False
                else:
                    index += 1
            return True

        while index < n - 1:
            if nums[index + 1] < nums[index]:
                if index == 0:
                    return search(index + 1, n)
                else:
                    if nums[index + 1] < nums[index - 1]:
                        nums[index + 1] = nums[index]
                        return search(index + 1, n)
                    else:
                        return search(index + 1, n)
            else:
                index += 1
        return True



data = Solution()
nums = [4, 2, 3]
print(data.checkPossibility(nums))
